package cn.ac.jaas.isc.vegetable.admin.controller;

import cn.ac.jaas.isc.vegetable.admin.service.SysRouteConfService;
import cn.ac.jaas.isc.vegetable.common.core.util.R;
import cn.ac.jaas.isc.vegetable.common.log.annotation.SysLog;
import cn.hutool.json.JSONArray;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author 张高昌
 * @date 2022/4/28 18:16
 * @description: 动态路由控制层
 */
@RestController
@AllArgsConstructor
@RequestMapping("/route")
@Api(value = "route", tags = "动态路由管理模块")
public class SysRouteConfController {

    private final SysRouteConfService sysRouteConfService;

    /**
     * 获取当前定义的路由信息
     *
     * @return
     */
    @GetMapping
    public R listRoutes() {
        return R.ok(sysRouteConfService.list());
    }

    /**
     * 修改路由
     *
     * @param routes 路由定义
     * @return
     */
    @SysLog("修改路由")
    @PutMapping
    public R updateRoutes(@RequestBody JSONArray routes) {
        return R.ok(sysRouteConfService.updateRoutes(routes));
    }
}
